
import java.util.*;

public class ZComparator implements Comparator<Card> {
	public int compare(Card c1, Card c2) {
		int diff = c1.getZ() - c2.getZ();
		if (diff!=0) {
			return diff;
		} else {
			// if the cards have the same z-value, they are still not considered equal unless they have the same id
			return c1.getID() - c2.getID();
		}
	}
	
	public static void sort(List<Card> cards) {
		Collections.sort(cards, new ZComparator());
	}
}

